window.Modernizr.touch && window.FastClick.attach(document.body);
var initData = {
    axisSize: 3,
    opacityArr: [.8, .6, .4, .2, 0]
}
  , clientWidth = $(window).width() > 640 ? 640 : $(window).width();
$(document).ready(function() {
    function t(t) {
        return $(t).parent().parent().parent().parent().find(".img-cover-content")
    }
    var a = 0
      , i = $(".sliderBox")
      , e = $(".axisBox")
      , n = e.outerWidth();
    $(".range-x").width(Math.floor(n));
    var r = $(".bar")
      , s = 40;
    r.draggable({
        axis: "x"
    });
    var o = n / initData.axisSize
      , d = (n - 12 * (initData.axisSize + 1)) / initData.axisSize
      , f = i.find(".one-axis-label");
    f.each(function(t) {
        t < f.length - 1 && $(this).css({
            "padding-right": d + "px"
        })
    });
    var c = function(t, a, i) {

        console.log(i && i === !0 );

        null  === a && (a = ".bar"),
        0 > t && (t = 0);
        var e = $(a).parent().find(".range-selected")
          , r = $(a).parent().find(".range-y");
        return e.width(n / initData.axisSize * t),
        r.each(function(a) {
            t > a ? $(this).addClass("range-highlight") : $(this).removeClass("range-highlight")
        }),
        i && i === !0 ? void $(a).css("left", 100 / initData.axisSize * t + "%") : void $(a).animate({
            left: 100 / initData.axisSize * t + "%"
        }, 200)
    }
    ;
    window.tianlogC = 0;
    var l = {
        offsetX: 0,
        offsetY: 0,
        startX: 0,
        startY: 0,
        lastX: 0,
        lastY: 0,
        nowX: 0,
        nowY: 0,
        distX: 0,
        distY: 0,
        dirAx: 0,
        dirX: 0,
        dirY: 0,
        lastDirX: 0,
        lastDirY: 0,
        distAxX: 0,
        distAxY: 0
    }
      , h = function(t) {
        t.preventDefault();
        {
            var a = $(t.currentTarget);
            a.position().left
        }
    }
      , g = function(i, e) {
        e = $(i.currentTarget),
        l.offsetX = void 0 !== i.offsetX ? i.offsetX : i.pageX - e.offset().left,
        l.offsetY = void 0 !== i.offsetY ? i.offsetY : i.pageY - e.offset().top,
        l.startX = l.lastX = i.pageX,
        l.startY = l.lastY = i.pageY;
        var r = e.position().left
          , d = Math.round(r / o);
        a = r,
        0 - s / 2 >= r ? e.position().left = 0 - s / 2 : r >= n + s / 2 && (e.position().left = n + s / 2),
        t(i.currentTarget).css({
            left: -(e.position().left * clientWidth * initData.axisSize / n) + "px"
        });
        var f = $(i.currentTarget).parent().find(".range-selected")
          , c = $(i.currentTarget).parent().find(".range-y");
        f.width(r),
        c.each(function(t) {
            d > t ? $(this).addClass("range-highlight") : $(this).removeClass("range-highlight")
        }),
        i.preventDefault()
    }
      , u = function(i) {
        var e = a;
        0 - s / 2 >= e ? e = 0 - s / 2 : e >= n + s / 2 && (e = n + s / 2);
        var r = Math.round(e / o);
        r > initData.axisSize ? r = initData.axisSize : 0 > r && (r = 0),
        $(i.currentTarget).parent().parent().attr("data-selectindex", r + ""),
        c(r, i.currentTarget),
        t(i.currentTarget).animate({
            left: -(r * clientWidth) + "px"
        }, 200),
        i.preventDefault()
    }
    ;
    r.on("touchstart", h),
    r.on("touchmove", g),
    r.on("touchend", u),
    i.on("click", function(a) {
        var e = $(a.currentTarget)
          , d = a.clientX - i.offset().left;
        t(a.currentTarget).css({
            left: -(e.position().left * clientWidth * initData.axisSize / n) + "px"
        });
        var f = $(a.currentTarget).parent().find(".range-selected")
          , l = $(a.currentTarget).parent().find(".range-y");
        f.width(d);
        var h = Math.round(d / o);
        r.css("left", d + "px"),
        l.each(function(t) {
            h > t ? $(this).addClass("range-highlight") : $(this).removeClass("range-highlight")
        }),
        setTimeout(function() {
            0 - s / 2 >= d ? d = 0 - s / 2 : d >= n + s / 2 && (d = n + s / 2);
            var i = Math.round(d / o);
            i > initData.axisSize ? i = initData.axisSize : 0 > i && (i = 0);
            var e = $(a.currentTarget).find(".bar");
            e.parent().parent().attr("data-selectindex", i + ""),
            c(i, e),
            t(e).animate({
                left: -(i * clientWidth) + "px"
            }, 0)
        }, 0)
    })
});
